package com.netty.constant;

import io.netty.handler.traffic.GlobalTrafficShapingHandler;
import io.netty.util.AttributeKey;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
import io.netty.util.concurrent.EventExecutorGroup;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Constants {

    public static ExecutorService executorService = Executors.newFixedThreadPool(10);
    private static EventExecutorGroup EXECUTOR_GROUOP = new DefaultEventExecutorGroup(Runtime.getRuntime().availableProcessors() * 2);
    public static final GlobalTrafficShapingHandler TRAFFICHANDLER = new GlobalTrafficShapingHandler(EXECUTOR_GROUOP, 30, 30);

    public interface ImserverConfig {
        //连接空闲时间
        int READ_IDLE_TIME = 60;//秒
        //发送心跳包循环时间
        int WRITE_IDLE_TIME = 30;//秒
        //心跳响应 超时时间
        int PING_TIME_OUT = 3; // 心跳响应超时次数
        // 最大协议包长度
        int MAX_FRAME_LENGTH = 1024 * 10; // 10k

        int MAX_AGGREGATED_CONTENT_LENGTH = 65536;

        String SOCKET = "0";//socket标识

        String WEBSOCKET = "1";//websocket标识

        String UDPSOCKET = "2";//udpsocket标识

    }

    public interface ImClientConfig {
        //连接空闲时间
        int READ_IDLE_TIME = 30;//秒
        //发送心跳包循环时间
        int WRITE_IDLE_TIME = 10;//秒
    }


    public interface SessionConfig {
        AttributeKey<Integer> PING_COUNT = AttributeKey.valueOf("ping_count");
        AttributeKey<String> UID = AttributeKey.valueOf("uid");
        AttributeKey<String> CHANNEL = AttributeKey.valueOf("channel");
        AttributeKey<String> ID = AttributeKey.valueOf("id");
        AttributeKey<String> SIPS = AttributeKey.valueOf("sip");
        AttributeKey<Integer> SPORT = AttributeKey.valueOf("sport");
        AttributeKey<String> UIPS = AttributeKey.valueOf("uip");
        AttributeKey<Integer> UPORT = AttributeKey.valueOf("uport");
    }

    public interface CmdType {
        int PONG = 0;
        int PING = 1;
        int MESSAGE = 2;
        int ONLINE = 3;  //上线
        int OFFLINE = 4; //下线
    }

}
